<?php

function dbconnect() 
	{ 
		require('config.php'); 
		static $connect = null; 
		if ($connect === null) 
			{
				 $connect =  mysql_connect($host, $user, $passwd) or die(mysql_error());
				 mysql_query("SET character_set_results=utf8", $connect);
				 mysql_select_db($database); 
			} 
			
		return $connect; 
	} 
function getid_auto_increment()
			{
		
		$r= mysql_query("SHOW TABLE STATUS LIKE 'Nhom_bai_viet'",dbconnect());
		$row = mysql_fetch_array($r); 
        $n = $row['Auto_increment']; 
        return $n;
		
		} 	
		
function insert_nhomtt($ntt) 
		{ 
		$query= mysql_query("INSERT INTO Nhom_bai_viet SET Ten_nhom_bai_viet=N'".$ntt['Ten_nhom_bai_viet']."' ", dbconnect());  
		}
function getbyid_nbv($id)
	{
		$result= mysql_query("SELECT * FROM Nhom_bai_viet WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}
function update_nbv($post)
	{
	$query= mysql_query("UPDATE Nhom_bai_viet SET Ten_nhom_bai_viet=N'".$post['Ten_nhom_bai_viet']."' WHERE ID=N'".$post['ID']."'",dbconnect()); 	
	}
?>